package com.lee.mysql.controller;

import com.lee.mysql.pojo.User;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class PageController {


    // 登录页面
    @RequestMapping(value = "/index")
    public String loginIndex(Model model) {

        //User user = (User) SecurityUtils.getSubject().getPrincipal();
        //model.addAttribute("user", user);

        return "index";
    }


    // 菜单页面
    @RequiresPermissions("system:menu:view")
    @RequestMapping(value = "/sys/menu")
    public String loadMenu() {
        return "menu";
    }

    @RequestMapping(value = "/sys/menu/edit")
    public String menuEdit() {
        return "menu_edit";
    }

    @RequestMapping(value = "/sys/menu/tree")
    public String menuTree() {
        return "menu_tree";
    }

    // 角色页面
    @RequiresPermissions("system:role:view")
    @RequestMapping(value = "/sys/role")
    public String loadRole() {
        return "role";
    }

    @RequestMapping(value = "/sys/role/edit")
    public String roleEdit() {
        return "role_edit";
    }

    @RequestMapping(value = "/sys/role/menu")
    public String roleMenu() {
        return "role_menu";
    }


    // 用户页面
    @RequiresPermissions("system:user:view")
    @RequestMapping(value = "/sys/user")
    public String loadUser() {
        return "user";
    }

    @RequestMapping(value = "/sys/user/edit")
    public String userEdit() {
        return "user_edit";
    }

    // 修改密码
    @RequestMapping(value = "/sys/user/pwd")
    public String updatePwd() {
        return "user_pwd";
    }

    // 修改资料
    @RequestMapping(value = "/sys/user/info")
    public String updateUserInfo() {
        return "user_info";
    }


    // 配置页面
    @RequiresPermissions("system:tabConfig:view")
    @RequestMapping(value = "/sys/tabConfig")
    public String loadTabConfig() {
        return "tabConfig";
    }

    // 配置页面
    @RequestMapping(value = "/sys/tabConfig/edit")
    public String editTabConfig() {
        return "tabConfig_edit";
    }

    // 数据库配置列表
    @RequiresPermissions("system:dbInfo:view")
    @RequestMapping(value = "/sys/dbInfo/page")
    public String editDbPage() {
        return "dbInfo_page";
    }

    // 数据库配置页面
    @RequestMapping(value = "/sys/dbInfo/edit")
    public String editDbInfo() {
        return "dbInfo_edit";
    }

    // 数据库结构同步操作
    @RequiresPermissions("system:tabSync:view")
    @RequestMapping(value = "/sys/tab/sync")
    public String tabSync() {
        return "tab_sync";
    }


    // 单表同步操作
    @RequiresPermissions("system:tabSync:one")
    @RequestMapping(value = "/sys/sync/one")
    public String syncOne() {
        return "sync_one";
    }

    // 多表同步操作
    @RequiresPermissions("system:tabSync:some")
    @RequestMapping(value = "/sys/sync/some")
    public String syncSome() {
        return "sync_some";
    }

    // 全表同步操作
    @RequiresPermissions("system:tabSync:all")
    @RequestMapping(value = "/sys/sync/all")
    public String syncAll() {
        return "sync_all";
    }

    // 配置列表
    @RequestMapping(value = "/sys/config/tree")
    public String configTree() {
        return "sync_config_tree";
    }

    // 数据表列表
    @RequestMapping(value = "/sys/tab/tree")
    public String tabTree() {
        return "sync_tab_tree";
    }

    // 视图列表(多选)
    @RequestMapping(value = "/sys/view/tree")
    public String tabViewTree() {
        return "sync_view_tree";
    }

    // 函数列表(多选)
    @RequestMapping(value = "/sys/fun/tree")
    public String tabFunTree() {
        return "sync_fun_tree";
    }

    // 数据表列表(多选)
    @RequestMapping(value = "/sys/check/tree")
    public String tabCheckTree() {
        return "sync_check_tree";
    }


    // 视图同步操作
    @RequiresPermissions("system:viewSync:view")
    @RequestMapping(value = "/sys/view/sync")
    public String viewSync() {
        return "view_sync";
    }

    // 函数同步操作
    @RequiresPermissions("system:funSync:view")
    @RequestMapping(value = "/sys/fun/sync")
    public String funSync() {
        return "fun_sync";
    }

    // 数据同步操作
    @RequiresPermissions("system:dataSync:view")
    @RequestMapping(value = "/sys/data/sync")
    public String dataSync() {
        return "data_sync";
    }



//    /**
//     * 页面模通用访问方法
//     */
//    @RequestMapping("sys/{modelUI}")
//    public String doPages(@PathVariable String modelUI) {
//        return modelUI;
//    }



}
